import { Navigate, useLocation } from "react-router-dom";

// eslint-disable-next-line react/prop-types
export default  function PrivateRoute({ children }) {
  let location = useLocation();
  let token = localStorage.getItem('userInfo'); // 假设你把token存储在localStorage

  return (
    token ? children : <Navigate to="/login" state={{ from: location }} />
  );
}